package com.tensquare.article.dao;

import org.springframework.data.jpa.repository.*;

import com.tensquare.article.pojo.Article;

/**
 * 数据访问接口
 *
 * @author Administrator
 */
public interface ArticleDao extends JpaRepository<Article, String>, JpaSpecificationExecutor<Article> {
    /**
     * 文章审核
     * Jpa所有的增删改都需要加上Modifying,nativeQuery是允许SQL表名
     */
    @Modifying
    @Query(value = "UPDATE tb_article SET state = ?1 WHERE id = ?2", nativeQuery = true)
    public void updateState(String state, String id);

    /**
     * 文章点赞
     */
    @Modifying
    @Query(value = "UPDATE tb_article SET thumbup = thumbup + 1 WHERE id = ?", nativeQuery = true)
    public void addThumbup(String id);

}
